package com.jwthhealth_pub.common;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by liuzhen000 on 2016/11/25.
 */

public class RegularUtil {
    public static boolean checkPhoneNumber(String phoneNumber) {
        Pattern pattern = Pattern.compile("^((13[0-9])|(14[5,7])|(15[^4,\\D])|(17[6-8])|(18[0-9]))\\d{8}$");
        Matcher matcher = pattern.matcher(phoneNumber);
        return matcher.matches();
    }

    public static boolean checkIdentityId(String id) {
//        Pattern pattern= Pattern.compile("/^(^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$)|(^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])((\\d{4})|\\d{3}[Xx])$)$/");
//        Matcher matcher=pattern.matcher(id);
//        return matcher.matches();
        String regx = "[0-9]{17}x";
        String reg1 = "[0-9]{15}";
        String regex = "[0-9]{18}";
        return id.matches(regx) || id.matches(reg1) || id.matches(regex);
    }

    public static boolean isInteger(String str) {

        float f = Float.parseFloat(str);
        float v = f % 1;
        return v == 0;

    }
}
